#coding=utf-8
import web
from app.configs import render
from app.configs.settings import db

class Login:
    
    def GET(self):
        return render.user.login()

    def POST(self):
        i=web.input()
        login_name=i.get('login_name',None)
        password=i.get('password',None)
        where='loginName=$login_name and password=$password';
        param=dict(login_name=login_name,password=password)
        resu=db.select('t_user',param,where=where)
        errors=dict(login_error='用户名或密码错误')
        if(not resu):
            return render.user.login(param,errors=errors)
        else:
            raise web.seeother('/index')


class Query:
    
    def GET(self):
        i=web.input()
        page=int(i.get('page','1'))
        page_size=int(i.get('page_size','20'))
        list = db.select('t_user') 
        return render.user.list(list)